<?php
$this->pageTitle = CHtml::encode($model->title);
$this->breadcrumbs=array(
	'Thông báo'=>array('index'),
	CHtml::encode($model->title),
);
?>
<div class="heading">
    <h1><img src="<?php echo Util::themeUrl() ?>/images/header.ico" /><?php echo $this->pageTitle; ?></h1>
    <div class="controls">
    	<?php
    		$form=$this->beginWidget('CActiveForm', array(
						'id'=>'statistic-excel-form',
						'enableAjaxValidation'=>false,
						'action' => array('downloadExcel')
					));
			//echo CHtml::submitButton('Thống kê', array('class' => 'controls'));
			//echo CHtml::hiddenField('id', $model->id);
		?>

        <?php
        //echo CHtml::button('Danh sách thành viên', array('class' => 'controls', 'onclick' => "location.href='" . $this->createUrl('assign', array('id' => $model->id, 'ajax' => true)) . "'"));
        if (isset($_GET['ajax'])) {
        	echo CHtml::button('Chọn thành viên', array('class' => 'controls', 'onclick' => "location.href='" . $this->createUrl('assign', array('id' => $model->id, 'ajax' => true)) . "'"));
            echo CHtml::button('Cập nhật', array('class' => 'controls', 'onclick' => "location.href='" . $this->createUrl('update', array('id' => $model->id, 'ajax' => true)) . "'"));
            echo CHtml::ajaxButton('Xóa', array('delete', 'ajax' => true), array(
                'type' => 'post',
                'data' => "chk[]={$model->id}",
                'success' => 'function(data){$(".controls").hide(); $(".content").html(data);}'
             ), array('class' => 'controls', 'confirm'=> 'Bạn có chắc chắn xóa dữ liệu này?'));
        } else {
        	echo CHtml::button('Chọn thành viên', array('class' => 'controls', 'onclick' => "location.href='" . $this->createUrl('assign', array('id' => $model->id)) . "'"));
            echo CHtml::link('Cập nhật', array('update', 'id' => $model->id), array('class' => 'controls'));
            echo CHtml::link('Xóa', array('delete'), array(
                'class' => 'controls',
                'submit' => array('delete'),
                'confirm'=>'Bạn có chắc chắn xóa dữ liệu này?',
                'params' => array('chk[]' => $model->id),
                'ajax' => array('type' => 'post')
            ));
        }
        //$this->endWidget();
     ?>
    </div>
</div>

<div class="content">
	<div class="user-profile">
		<table cellpadding="0" cellspacing="0" width="100%">
			<tbody>
				<tr valign="top">
					<td width="230px;" class="left-column" style="vertical-align: top">
						<div class="">
			              	<?php
			              		if (isset($_GET['ajax'])) {
			              			$aViewAssign = array('viewAssign', 'id' => $model->id, 'ajax' => true);
			              		}
			              		else {
			              			$aViewAssign = array('viewAssign', 'id' => $model->id);
			              		}
								echo CHtml::hiddenField('id', $model->id);
								echo CHtml::link('Danh sách thành viên', $aViewAssign, array('class' => 'button'));
								echo "&nbsp;&nbsp;&nbsp;";
								echo CHtml::imageButton(Util::themeUrl() . '/images/download_icon.png', array('id' => 'downloadExcel', 'class' => 'button-excel btn'));
								$this->endWidget();
							?>
						</div>
						<div class="clear"></div>

						<table class="table-bordered">
				          <tbody>
				          <?php if ($model->event_fg == 1) :?>
				            <tr>
				              <td>Số thành viên mời tham dự</td>
				              <td width="20px;" class="td-number">
									<strong><?php echo isset($model->assigns[0]) ? $model->assigns[0]->count_assign : 0;?></strong>
				              </td>
				            </tr>
				            <tr>
				              <td>Số thành viên đã xem</td>
				               <td class="td-number">
									<strong id="statistic-asigned"><?php echo isset($model->assigns[0]) ? $model->assigns[0]->count_view : 0;?></strong>
				              </td>
				            </tr>
				            <tr>
				              <td>Số thành viên không phản hồi</td>
				              <td class="td-number">
									<strong  id="statistic-absence"><?php echo isset($model->assigns[0]) ? $model->assigns[0]->count_no_reply: 0;?></strong>
				              </td>
				            </tr>
				            <tr>
				              <td>Số thành viên dự kiến tham dự</td>
				              <td class="td-number">
									<strong  id="statistic-absence"><?php echo isset($model->assigns[0]) ? $model->assigns[0]->count_purpose_join: 0;?></strong>
				              </td>
				            </tr>
				            <tr>
				              <td>Số thành viên dự kiến không tham dự</td>
				              <td class="td-number">
									<strong  id="statistic-absence"><?php echo isset($model->assigns[0]) ? $model->assigns[0]->count_no_join: 0;?></strong>
				              </td>
				            </tr>
				            <?php if ($model->status == 0) :?>
				            <tr>
				              <td>Số thành viên tham dự</td>
				             <td class="td-number">
									<strong  id="statistic-joined"><?php echo isset($model->assigns[0]) ? $model->assigns[0]->count_joined: 0;?></strong>
				              </td>
				            </tr>
				            <?php endif;?>
				            <?php else :?>
				            <tr>
				              <td>Số thành viên được xem</td>
				              <td width="20px;" class="td-number">
									<strong><?php echo isset($model->assigns[0]) ? $model->assigns[0]->count_assign : 0;?></strong>
				              </td>
				            </tr>
				            <tr>
				              <td>Số thành viên đã xem</td>
				               <td class="td-number">
									<strong id="statistic-asigned"><?php echo isset($model->assigns[0]) ? $model->assigns[0]->count_view : 0;?></strong>
				              </td>
				            </tr>
				            <?php endif;?>
				          </tbody>
				        </table>
					</td>
					<td class="right-column fieldset-none" style="vertical-align: top">
						<div class = "div-fieldset">
							<ul id = 'announcements-list'>
								<li><span><?php echo $model->content;?></span></li>
								<?php echo Util::convertDateToVN($model->created);?>
							</ul>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</div>
